//
//  YADateFormat.m
//  YASDK
//
//  Created by 郑逸凯 on 2018/12/14.
//  Copyright © 2018年 郑逸凯. All rights reserved.
//

#import "YADateFormat.h"

@implementation YADateFormat


//传入 秒  得到 xx:xx:xx
+ (NSString *)getHHMMSSFromSS:(NSString *)totalTime{
    
    NSInteger seconds = [totalTime integerValue];
    
    //format of hour
    NSString *str_hour = [NSString stringWithFormat:@"%02ld",seconds/3600];
    //format of minute
    NSString *str_minute = [NSString stringWithFormat:@"%02ld",(seconds%3600)/60];
    //format of second
    NSString *str_second = [NSString stringWithFormat:@"%02ld",seconds%60];
    //format of time
    NSString *format_time = [NSString stringWithFormat:@"%@:%@:%@",str_hour,str_minute,str_second];
    
    return format_time;
    
}

+ (NSString *)getHHMMSSAutoHideHHFromSS:(NSString *)totalTime {
    NSString *string = [self getHHMMSSFromSS:totalTime];
    if ([string hasPrefix:@"00:"]) {
        return [string substringFromIndex:3];
    }else {
        return string;
    }
}

//传入 秒  得到  xx分钟xx秒
+ (NSString *)getMMSSFromSS:(NSString *)totalTime {
    
    
    NSInteger seconds = [totalTime integerValue];
    
    //format of minute
    NSString *str_minute = [NSString stringWithFormat:@"%02ld",seconds/60];
    //format of second
    NSString *str_second = [NSString stringWithFormat:@"%02ld",seconds%60];
    //format of time
    NSString *format_time = [NSString stringWithFormat:@"%@:%@",str_minute,str_second];
    
//    NSLog(@"format_time : %@",format_time);
    
    return format_time;
    
}


@end
